package com.example.huainanlive.adapter

import android.graphics.Color
import android.widget.ImageView
import android.widget.TextView
import coil.load
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.huainanlive.R
import com.example.huainanlive.bean.GetLiveHousePreviewBeanItem

class LiveHousePreviewAdapter: BaseQuickAdapter<GetLiveHousePreviewBeanItem, BaseViewHolder>(R.layout.item_live_house_preview) {

    init {
        addChildClickViewIds(R.id.addSub)
    }


    override fun convert(holder: BaseViewHolder, item: GetLiveHousePreviewBeanItem) {

        holder.getViewOrNull<TextView>(R.id.liveTitle)?.text = item.liveTitle
        holder.getViewOrNull<TextView>(R.id.liveStartTime)?.text = item.liveStartTime
        holder.getViewOrNull<ImageView>(R.id.livePreview)?.load(item.liveCoverImg)
        if (item.sub == true){
            holder.getViewOrNull<TextView>(R.id.addSub)?.text = "已预约"
            holder.getViewOrNull<TextView>(R.id.addSub)?.setBackgroundColor(Color.parseColor("#B0B0B0"))

        }else{
            holder.getViewOrNull<TextView>(R.id.addSub)?.text = "未预约"
            holder.getViewOrNull<TextView>(R.id.addSub)?.setBackgroundColor(Color.parseColor("#DB2C1A"))
        }

    }
}